﻿using System.Windows;
using System.Windows.Forms;
using Spriter.Ui.ViewModels.UserControls;

namespace Spriter.Ui.UserControls
{
    /// <summary>
    ///     Interaction logic for FilePicker.xaml
    /// </summary>
    public partial class FilePicker
    {
        public readonly FilesPickerViewModel ViewModel;

        public FilePicker()
        {
            ViewModel = new FilesPickerViewModel();
            DataContext = ViewModel;
            InitializeComponent();
        }

        private void PickFiles(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog {Multiselect = true};

            var result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                ViewModel.Files.Clear();
                foreach (var file in dialog.FileNames)
                {
                    ViewModel.Files.Add(file);
                }
                FileCountPanel.Visibility = Visibility.Visible;
            }
        }
    }
}